package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.AOrders;
import com.ruoyi.system.domain.OrdersVo;
import com.ruoyi.system.domain.vo.OrderDetailsVo;
import com.ruoyi.system.service.IAOrdersService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单Controller
 * 
 * @author 王家宁
 * @date 2024-09-02
 */
@Controller
@RequestMapping("/system/user/orders")
public class MyOrdersController extends BaseController
{
    private String prefix = "/system/user/orders";

    @Autowired
    private IAOrdersService aOrdersService;


    @RequiresPermissions("system:orders:user:view")
    @GetMapping()
    public String getUserOrders()
    {
        return prefix + "/myList";
    }

    @PostMapping("/myList")
    @ResponseBody
    public TableDataInfo myList()
    {
        startPage();
        List<OrdersVo> list = aOrdersService.selectMyOrders();
        return getDataTable(list);
    }

    @GetMapping("/read/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        OrderDetailsVo orderDetails = aOrdersService.getOrderDetails(id);
        mmap.put("orderDetails", orderDetails);
        return prefix + "/orders_details";
    }
}
